import 'package:flutter/material.dart';

import '../util/print_util.dart';

typedef ItemOnLick = void Function();

class CatalogueItemWidget extends StatelessWidget {
  final ItemOnLick _itemOnLick;
  final String _itemTitle;

  const CatalogueItemWidget(ItemOnLick itemOnLick, String itemTitle,
      {super.key})
      : _itemOnLick = itemOnLick,
        _itemTitle = itemTitle;

  CatalogueItemWidget.fromMap(map, {super.key})
      : _itemOnLick = map["itemOnLick"],
        _itemTitle = map["itemTitle"];

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: const EdgeInsets.symmetric(vertical: 5),
      child: Row(
        mainAxisSize: MainAxisSize.max,
        children: [
          Expanded(
              child: TextButton(
                  onPressed: () {
                    LoggerUtil.d("_itemTitle");
                    // context.read<PageNavigationCubit>().toWebViewPage();
                    _itemOnLick.call();
                  },
                  child: Text(
                    _itemTitle,
                    style: const TextStyle(
                        color: Colors.black54,
                        fontStyle: FontStyle.italic,
                        decoration: TextDecoration.underline),
                  ))),
        ],
      ),
    );
  }
}
